class GirlFriend{
	private String name;//成员变量
	private int age;
	
	public void method(){
		int age = 10;
		System.out.println(age);//就近原则:10
		System.out.println(this.age);//打印成员变量:0
		
	}
	public void method1(){
		System.out.println(age);//打印成员变量:0
		System.out.println(this.age);//打印成员变量:0
	}
	
	public void setName(String name){
		this.name = name;
	}
	public String getName(){
		return name;
	}
	public void setAge(int age){
		if(age >= 18 && age <= 25){
			this.age = age;
		}else{
			System.out.println("非法参数");
		}
	}
	public int getAge(){
		return age;
	}
	
	
}

public class A19{
	public static void main(String[] args){
		GirlFriend gf1 = new GirlFriend();
		gf1.method();
		gf1.method1();
		//gf1.name = "晨";这是错的,private修饰了,属于GirlFriend类的私有,不能直接赋值
		gf1.setName("晨");
		gf1.setAge(21);
	
		
		System.out.println(gf1.getName());
		System.out.println(gf1.getAge());
		
	}
	
	
	
}